package com.hdu.point_offer;

import java.util.HashSet;
import java.util.Set;

public class lcr186 {
    class Solution {
        public boolean checkDynasty(int[] places) {
            Set<Integer> set = new HashSet<>();
            int min = Integer.MAX_VALUE;
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < places.length; i++) {
                if (places[i] != 0) {
                    if (set.contains(places[i])) return false;
                    set.add(places[i]);
                    min = Math.min(min, places[i]);
                    max = Math.max(max, places[i]);
                }
            }
            return max - min < 5;
        }
    }
}
